home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et-2_2.lha / et2.2 / src / Buttons.h < prev    next >
C/C++ Source or Header  |  1990-12-05  |  4KB  |  138 lines

  1. #ifndef Button_First
  2. #ifdef __GNUG__
  3. #pragma once
  4. #endif
  5. #define Button_First
  6.  
  7. #include "VObject.h"
  8. #include "VObjectPair.h"
  9.  
  10. //---- Button ------------------------------------------------------------------
  11.   
  12. enum ButtonFlags {
  13.     eButtonIdle     =   BIT(eCompVObjLast+1),
  14.     eButtonLast     =   eCompVObjLast + 1,
  15.     eButtonDefault  =   eCompVObjDefault
  16. };
  17.  
  18. class Button: public CompositeVObject {
  19. public:
  20.     MetaDef(Button);
  21.     Button(int id= cIdNone, VObject *gop= 0);
  22.     Command *DoLeftButtonDownCommand(Point, Token, int);
  23.     void DoOnItem(int, VObject*, Point);
  24.     virtual void Flush(int msec= 200);
  25. };
  26.  
  27. //---- ButtonCommand -----------------------------------------------------------
  28.  
  29. class ButtonCommand: public Command {
  30.     Button *item;
  31.     bool lastinside, inside;
  32.     Rectangle rect;
  33. public:
  34.     ButtonCommand(Button*, Rectangle, bool b= FALSE);
  35.     void TrackFeedback(Point, Point, bool);
  36.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  37. };
  38.  
  39. //---- ActionButton ------------------------------------------------------------
  40.  
  41. enum ActionButtonFlags {
  42.     eActionDefaultButton  = BIT(eButtonLast+1),
  43.     eActionButtonLast     = eButtonLast+1
  44. };
  45.  
  46. class ActionButton: public Button {
  47. public:
  48.     MetaDef(ActionButton);
  49.     ActionButton(int id= cIdNone, VObject *g= 0, bool dflt= FALSE);
  50.     ActionButton(int id, char *t, bool dflt= FALSE);
  51.     
  52.     int CalcBorder()
  53.     { return TestFlag(eActionDefaultButton) ? 6 : 2; }
  54.     Metric GetMinSize();
  55.     int Base();
  56.     void SetOrigin(Point);
  57.     void SetExtent(Point e);
  58.     void Draw(Rectangle);
  59.     void DrawHighlight(Rectangle);
  60.     void Control(int, int, void*);
  61.     void SetContainer(VObject*);
  62. };
  63.  
  64. //---- ImageButton -------------------------------------------------------------
  65.  
  66. class ImageButton: public Button {
  67. protected:
  68.     bool idleEvents;
  69.     Bitmap *bm1, *bm2;
  70. public:
  71.     MetaDef(ImageButton);
  72.     ImageButton(int id= cIdNone, Bitmap *b1= 0, Bitmap *b2= 0, bool idle= FALSE);
  73.     ~ImageButton();
  74.     Metric GetMinSize();
  75.     void DrawInner(Rectangle r, bool highlight);
  76.     Command *DoLeftButtonDownCommand(Point, Token, int);
  77.     ostream& PrintOn (ostream&s);
  78.     istream& ReadFrom(istream &);
  79. };
  80.  
  81. //---- OnOffItem ---------------------------------------------------------------
  82.   
  83. class OnOffItem: public Button {
  84. protected:
  85.     Bitmap *on, *off, *highlight;
  86.     bool state;
  87. public:
  88.     MetaDef(OnOffItem);
  89.     OnOffItem(int id, Bitmap*, Bitmap*, Bitmap*, bool);
  90.     void SetState(bool, bool redraw= TRUE);
  91.     bool GetValue()
  92.     { return state; }
  93.     void SendDown(int, int, void*);
  94.     void DoOnItem(int, VObject*, Point);
  95.     Metric GetMinSize();
  96.     int Base();
  97.     void Draw(Rectangle);
  98.     ostream& PrintOn (ostream&s);
  99.     istream& ReadFrom(istream &);
  100. };
  101.  
  102. //---- RadioButton -------------------------------------------------------------
  103.  
  104. class RadioButton: public OnOffItem {
  105. public:
  106.     MetaDef(RadioButton);
  107.     RadioButton(int id= cIdNone, bool state = FALSE);
  108.     void InitNew();
  109.     ostream& PrintOn (ostream&s);
  110.     istream& ReadFrom(istream &);
  111. };
  112.  
  113. //---- ToggleButton ------------------------------------------------------------
  114.  
  115. class ToggleButton: public OnOffItem {
  116. public:
  117.     MetaDef(ToggleButton);
  118.     ToggleButton(int id= cIdNone, bool state = FALSE);
  119.     void InitNew();
  120.     ostream& PrintOn (ostream&s);
  121.     istream& ReadFrom(istream &);
  122. };
  123.  
  124. //---- LabeledButton -----------------------------------------------------------
  125.  
  126. class LabeledButton: public VObjectPair {
  127. public:
  128.     MetaDef(LabeledButton);
  129.     LabeledButton(int id= cIdNone, OnOffItem *b= 0, VObject *g= 0,
  130.                 Point gap= gPoint10, VObjAlign g= eVObjVBase);
  131.     LabeledButton(int id, char *t, bool w= TRUE);
  132.     Command *DoLeftButtonDownCommand(Point, Token, int);
  133.     void Control(int, int, void*);
  134. };
  135.  
  136. #endif Button_First
  137.  
  138.